﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EAcancellations.aspx.cs" Inherits="StreetSmartAdmin.EAcancellations" %>
<%@ Register TagPrefix="CustUserCtrl" TagName="Header" Src="Header.ascx" %>
<%@ Register TagPrefix="CustUserCtrl" TagName="Footer" Src="Footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="javascript" type="text/javascript" src="WdatePicker.js"></script>
<head id="Head1" runat="server">
    <title>Street Smart Energy Admin</title>
    <link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
    <form id="form1" runat="server">
    <CustUserCtrl:Header ID="Header" runat="server"></CustUserCtrl:Header>
    <h3>
    <!--
    <asp:Label ID="Label1" runat="server" Text="Conversions Date"></asp:Label>
    <br/>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Export" />
    -->
    <asp:TextBox ID="TextBox1" runat="server" onclick="WdatePicker()" visible="false"></asp:TextBox>
    <br />
    <br />
    <asp:Label ID="Label2" runat="server" Text="Cancellation Date Range"></asp:Label>   
    <br />
    <asp:Label ID="Label3" runat="server" Text="From"></asp:Label>
    <asp:TextBox ID="TextBox2" runat="server" onclick="WdatePicker()" ></asp:TextBox>
    <asp:Label ID="Label4" runat="server" Text="To"></asp:Label>
    <asp:TextBox ID="TextBox3" runat="server" onclick="WdatePicker()" ></asp:TextBox>
        <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="Search" />
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Generate" />
    </h3>   
    <CustUserCtrl:Footer id="Footer" runat="server"></CustUserCtrl:Footer> 
    <asp:Label ID="Label5" runat="server" Text="Page Size :"></asp:Label>

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" 
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem Value="10">10</asp:ListItem>                                   
        <asp:ListItem Value="20">20</asp:ListItem>
        <asp:ListItem Value="50">50</asp:ListItem>
        <asp:ListItem Value="100">100</asp:ListItem>
        <asp:ListItem Value="200">200</asp:ListItem>
        <asp:ListItem Value="500">500</asp:ListItem>
        <asp:ListItem Value="1000">1000</asp:ListItem>
    </asp:DropDownList>

    <asp:GridView ID="GridView1" runat="server" CssClass="mGrid"
            PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" 
            DataSourceID="SqlDataSource1" AutoGenerateColumns="False" 
            AllowPaging="True" DataKeyNames="VERBAL_ACCEPTANCE_NO"
            onselectedindexchanged="GridView1_SelectedIndexChanged" 
            EnableModelValidation="True">
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
        <Columns>
            
            <asp:BoundField DataField="VERBAL_ACCEPTANCE_NO" 
                HeaderText="VERBAL_ACCEPTANCE_NO" SortExpression="VERBAL_ACCEPTANCE_NO" />
            <asp:BoundField DataField="CANCELLATION_DATE" HeaderText="CANCELLATION_DATE" 
                SortExpression="CANCELLATION_DATE" />
            <asp:BoundField DataField="CANCELLATED_BY" HeaderText="CANCELLATED_BY" 
                SortExpression="CANCELLATED_BY" />
            <asp:BoundField DataField="CANCELLATED_RESON" HeaderText="CANCELLATED_RESON" 
                SortExpression="CANCELLATED_RESON" />
            
            <asp:CommandField ShowEditButton="True" />
            <asp:CommandField ShowDeleteButton="True" />
            
        </Columns>

<PagerStyle CssClass="pgr"></PagerStyle>
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SQLServer2005DBConnectionString %>"       
        
        SelectCommand="SELECT * FROM [tblCancellation] where CANCELLATION_DATE = @Value order by CANCELLATION_DATE" 
        DeleteCommand="DELETE FROM tblCancellation where VERBAL_ACCEPTANCE_NO =@VERBAL_ACCEPTANCE_NO" 
        InsertCommand="INSERT INTO tblCancellation(VERBAL_ACCEPTANCE_NO, CANCELLATION_DATE, CANCELLATED_BY, CANCELLATED_RESON) VALUES (@VERBAL_ACCEPTANCE_NO, @CANCELLATION_DATE, @CANCELLATED_BY, @CANCELLATED_RESON)" 
        UpdateCommand="UPDATE tblCancellation SET CANCELLATION_DATE =@CANCELLATION_DATE, CANCELLATED_BY =@CANCELLATED_BY, CANCELLATED_RESON =@CANCELLATED_RESON where VERBAL_ACCEPTANCE_NO =@VERBAL_ACCEPTANCE_NO">
        <SelectParameters>
            <asp:ControlParameter ControlID="TextBox1" Name="Value" PropertyName="Text" 
                Type="String" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="VERBAL_ACCEPTANCE_NO" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="VERBAL_ACCEPTANCE_NO" />
            <asp:Parameter Name="CANCELLATION_DATE" />
            <asp:Parameter Name="CANCELLATED_BY" />
            <asp:Parameter Name="CANCELLATED_RESON" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="VERBAL_ACCEPTANCE_NO" />
            <asp:Parameter Name="CANCELLATION_DATE" />
            <asp:Parameter Name="CANCELLATED_BY" />
            <asp:Parameter Name="CANCELLATED_RESON" />
        </InsertParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SQLServer2005DBConnectionString %>"       
        SelectCommand="SELECT * FROM [tblCancellation] where CANCELLATION_DATE >= @Value1 and CANCELLATION_DATE <= @Value2 order by CANCELLATION_DATE">
        <SelectParameters>
                    <asp:ControlParameter ControlID="TextBox2" Name="Value1" Type="String" PropertyName="Text" /> 
                    <asp:ControlParameter ControlID="TextBox3" Name="Value2" Type="String" PropertyName="Text" /> 
        </SelectParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SQLServer2005DBConnectionString %>" 
        SelectCommand="SELECT * FROM [tblCancellation] WHERE VERBAL_ACCEPTANCE_NO=@VERBAL_ACCEPTANCE_NO"
        InsertCommand="INSERT INTO [tblCancellation] (VERBAL_ACCEPTANCE_NO,CANCELLATION_DATE,CANCELLATED_BY,CANCELLATED_RESON) VALUES (@VERBAL_ACCEPTANCE_NO,@CANCELLATION_DATE,@CANCELLATED_BY,@CANCELLATED_RESON)">
                        <SelectParameters>
							<asp:ControlParameter ControlID="GridView1" Name="UserID" PropertyName="selectedvalue" /> 
                        </SelectParameters>    
    </asp:SqlDataSource>

<asp:DetailsView ID="DetailsView1" runat="Server" CellPadding="4" ForeColor="#333333"
                        GridLines="None" DataSourceID="SqlDataSource3" 
        AllowPaging="True" AutoGenerateRows="False" AutoGenerateInsertButton="True" 
        DefaultMode="Insert" CssClass="mGrid" DataKeyNames="VERBAL_ACCEPTANCE_NO"
                        PagerStyle-CssClass="pgr" 
        AlternatingRowStyle-CssClass="alt" EnableModelValidation="True">
                        <Fields>
                            
                            <asp:TemplateField HeaderText="VERBAL_ACCEPTANCE_NO" 
                                SortExpression="VERBAL_ACCEPTANCE_NO">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" 
                                        Text='<%# Bind("VERBAL_ACCEPTANCE_NO") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" 
                                        Text='<%# Bind("VERBAL_ACCEPTANCE_NO") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                    <asp:TextBox ID="VERBAL_ACCEPTANCE_NO" runat="server" 
                                        Text='<%# Bind("VERBAL_ACCEPTANCE_NO") %>'></asp:TextBox>

                                    <asp:RequiredFieldValidator ID="VERBAL_ACCEPTANCE_NOVali" runat="server" 
                                            ControlToValidate="VERBAL_ACCEPTANCE_NO" ErrorMessage="*Required Field"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="VERBAL_ACCEPTANCE_NORE" runat="server" 
                                            ErrorMessage="XXXZZZZZZZ9 format(e.g. SSE00000001 XXX:Sale Channel Prefix ZZZZZZZ9:8 digits M1:Optional SME Multi-site No. )" 
                                            ControlToValidate="VERBAL_ACCEPTANCE_NO" ValidationExpression="^[a-zA-Z]{3}\d{8}"></asp:RegularExpressionValidator>



                                </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CANCELLATION_DATE" 
                                SortExpression="CANCELLATION_DATE">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("CANCELLATION_DATE") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" 
                                        Text='<%# Bind("CANCELLATION_DATE") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                    <asp:TextBox ID="CANCELLATION_DATE" runat="server" 
                                        onclick="WdatePicker()"
                                        Text='<%# Bind("CANCELLATION_DATE") %>'></asp:TextBox>

                                    <asp:RequiredFieldValidator ID="CANCELLATION_DATEVali" runat="server" 
                                            ControlToValidate="CANCELLATION_DATE" ErrorMessage="*Required Field"></asp:RequiredFieldValidator>
 

                                </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CANCELLATED_BY" SortExpression="CANCELLATED_BY">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("CANCELLATED_BY") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("CANCELLATED_BY") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                    <asp:TextBox ID="CANCELLATED_BY" runat="server" Text='<%# Bind("CANCELLATED_BY") %>'></asp:TextBox>
                                
                                    <asp:RequiredFieldValidator ID="CANCELLATED_BYVali" runat="server" 
                                            ControlToValidate="CANCELLATED_BY" ErrorMessage="*Required Field"></asp:RequiredFieldValidator>
 
                                
                                </InsertItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="CANCELLATED_RESON" 
                                SortExpression="CANCELLATED_RESON">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("CANCELLATED_RESON") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox4" runat="server" 
                                        Text='<%# Bind("CANCELLATED_RESON") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <InsertItemTemplate>
                                    <asp:TextBox ID="CANCELLATED_RESON" runat="server" 
                                        Text='<%# Bind("CANCELLATED_RESON") %>'></asp:TextBox>

                                    <asp:RequiredFieldValidator ID="CANCELLATED_RESONVali" runat="server" 
                                            ControlToValidate="CANCELLATED_RESON" ErrorMessage="*Required Field"></asp:RequiredFieldValidator>
 
                                </InsertItemTemplate>
                            </asp:TemplateField>
                            
                        </Fields>
                        <AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>

                    <PagerStyle CssClass="pgr"></PagerStyle>
                    </asp:DetailsView>

    </form>
</body>

</html>


